package kr.hyunist.androidcomplete02saeildamil.ch20;

import kr.hyunist.androidcomplete02saeildamil.*;
import android.app.*;
import android.os.*;
import android.view.*;

public class DialogStyleThemeTest extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialogstylethemetest);
	}

	public void mOnClick(View v) {
		switch (v.getId()) {
		case R.id.dialogstylethemebtn1:
			showDialog(DialogFragment.STYLE_NORMAL, 0);
			break;
			
		case R.id.dialogstylethemebtn2:
			showDialog(DialogFragment.STYLE_NO_TITLE, 0);
			break;
			
		case R.id.dialogstylethemebtn3:
			showDialog(DialogFragment.STYLE_NO_FRAME, 0);
			break;
			
		case R.id.dialogstylethemebtn4:
			showDialog(DialogFragment.STYLE_NO_INPUT, 0);
			break;
			
		case R.id.dialogstylethemebtn5:
			showDialog(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Holo);
			break;
			
		case R.id.dialogstylethemebtn6:
			showDialog(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo_Dialog);
			break;
			
		case R.id.dialogstylethemebtn7:
			showDialog(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme_Holo_Light);
			break;
			
		case R.id.dialogstylethemebtn8:
			showDialog(DialogFragment.STYLE_NO_INPUT, android.R.style.Theme_Holo_Panel);
			break;
		}
	}

	private void showDialog(int style, int theme) {
		FragmentManager fm = getFragmentManager();
		FragmentTransaction ft = fm.beginTransaction();
		Fragment prev = fm.findFragmentByTag("dialog");
		
		if(prev != null){
			ft.remove(prev);
		}
		
		ft.addToBackStack(null);
		
		NameGenderFragment newFragment = NameGenderFragment.newInstance(style, theme);
		newFragment.show(ft, "dialog");
	}
}
